#pragma

#include <iostream>
#include <functional>
#include <vector>
#include <string>
#include <ctime>
#include <unistd.h>

using task_t = std::function<void()>;

void Download()
{
    std::cout << "我是下载任务" << std::endl;
}

void PrintLog()
{
    std::cout << "我是打印任务" << std::endl;
}

void PushVideoStream()
{
    std::cout << "我是推送视频流任务" << std::endl;
}

class Init
{
public:
    // 任务集合
std::vector<task_t> tasks;
    // 任务码
const static int g_download_code = 0;
const static int g_printlog_code = 1;
const static int g_pushvideostream_code = 2;
    Init()
    {
        tasks.push_back(Download);
        tasks.push_back(PrintLog);
        tasks.push_back(PushVideoStream);
        srand(time(nullptr) ^ getpid());
    }
    bool CheckSafe(int code)
    {
        if(code >= 0 && code < tasks.size()) return true;
        else return false;
    }
    void RunTask(int code)
    {
        return tasks[code]();
    }
    int SelectTask()
    {
        return rand() % tasks.size();
        
    }
    std::string ToDesc(int code)
    {
        switch(code)
        {
        case g_download_code:return "Download";
        case g_printlog_code:return "PrintLog";
        case g_pushvideostream_code:return "PushVideoStream";
        default:
            return "None";
        }
    }
};

Init init;



